<%@ page import="java.util.List" %>
<%@ page import="com.web.test.bean.Question" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.web.test.utils.Constants" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/22
  Time: 23:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>我的试卷</title>
</head>
<%@include file="webexam_left.jsp" %>
<style>
    #content {
        width: 80%;
        background-color: white;
        margin-top: 30px;
        margin-left: 100px;
    }

    input[type=text] {
        width: 400px;
        height: 80px;;
    }

    input[type=reset], input[type=submit] {
        border: none;
        background-color: aqua;
        padding-left: 30px;
        padding-right: 30px;
        height: 40px;
        color: black;
        font-size: 20px;
    }
</style>
<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
<body>
<%
    Map<Integer, List<Question>> questionsMap = (Map<Integer, List<Question>>) session.getAttribute("questionsMap");


%>
<div class="right">
    <div id="content">
        <center>
            <span style="font-size: 30px">试卷预览</span>
            <hr style="height: 1px;background-color: darkgray">
            <span style="color: red;font-size: 25px">A卷(总<%=session.getAttribute("total")%>分)</span>
        </center>
        <hr style="height: 1px;background-color: darkgray">
        <form id="form" method="post" action="/my_question" >
            <%
                if (questionsMap != null) {

                    for (Map.Entry<Integer, List<Question>> k : questionsMap.entrySet()) {

                        if (k.getKey() == Constants.ONLY_SELECT_Q) {
            %>

            <span style="margin-left: 20px;float: left;font-weight: 600;font-size: 25px">一、单选题</span>
            <br>

            <%
                for (Question question : k.getValue()) {%>


            <hr>
            <span style="margin-left: 20px;"><%=question.getTitle()%>(<%=question.getScore()%>分)</span>
            <br>

            <% for (String op : question.getOptions()) {
            %>


            <input style="margin-left: 40px" type="radio" name="radio<%=question.getNo()%>" value="<%=op%>"><%=op%>
            <input type="hidden" name="question_no" value="<%=question.getNo()%>">

            <%
                    }
                }%>

            <hr style="height: 1px;background-color: darkgray">


            <%
            } else if (k.getKey() == Constants.MULTI_SELECT_Q) {%>


            <span style="margin-left: 20px;float: left;font-weight: 600;font-size: 25px">二、多选题(错选不得分，全选对才得分)</span>
            <br>

            <%
                for (Question question : k.getValue()) {%>

            <hr>
            <span style="margin-left: 20px;"><%=question.getTitle()%>(<%=question.getScore()%>分)</span>
            <br>


            <% for (String op : question.getOptions()) {
            %>

            <input style="margin-left: 40px" type="checkbox" name="checkbox<%=question.getNo()%>"
                   value="<%=op%>"><%=op%>

            <%
                    }
                }%>

            <hr style="height: 1px;background-color: darkgray">


            <%
            } else if (k.getKey() == Constants.JUDGE_Q) {%>

            <span style="margin-left: 20px;float: left;font-weight: 600;font-size: 25px">三、判断题</span>
            <br>


            <%
                for (Question question : k.getValue()) {%>
            <hr>
            <span style="margin-left: 20px;"><%=question.getTitle()%>(<%=question.getScore()%>分)</span>
            <br>


            <input style="margin-left: 30px" type="radio" name="radio<%=question.getNo()%>" value="true">true
            <input style="" type="radio" name="radio<%=question.getNo()%>" value="false">false


            <%

                }%>

            <hr style="height: 1px;background-color: darkgray">


            <%
            } else if (k.getKey() == Constants.WRITE_Q) {%>

            <span style="margin-left: 20px;float: left;font-weight: 600;font-size: 25px">四、填空题</span>
            <br>


            <%
                for (Question question : k.getValue()) {%>

            <hr>
            <span style="margin-left: 20px;"><%=question.getTitle()%>(<%=question.getScore()%>分)</span>
            <br>


            <input style="margin-left: 30px" type="text" name="text<%=question.getNo()%>">


            <%

                }%>

            <hr style="height: 1px;background-color: darkgray">

            <% }
            }
            }
            %>
            <br>
            <center><input type="reset" value="重置">
                <%--<button  onclick="s()">交卷</button>--%>
                <input type="submit"  value="交卷">
                <span style="display: block;font-size: 30px;color: green" id="grade"></span>
            </center>
            <br>
            <br>

        </form>
        <%--<iframe name="ifr" id="ifr" style="display: none"></iframe>--%>

    </div>
</div>

<%--<script>--%>

    <%--function s() {--%>

        <%--$.ajax({--%>

            <%--url: "/my_question",--%>
            <%--data: $("#form").serialize(),--%>
            <%--type: "POST",--%>
            <%--dataType: "html",--%>
            <%--success: function (data) {--%>

                <%--$("#grade").html(data);--%>

            <%--}--%>
        <%--});--%>

    <%--}--%>

    <%--var iframe = document.getElementById("ifr");--%>


    <%--iframe.onload = function () {--%>

        <%--var bodycontent = iframe.contentDocument.body.innerHTML;--%>
        <%--console.log(bodycontent);--%>

    <%--}--%>


<%--</script>--%>
</body>
</html>
